package org.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.api.hint.HintManager;
import org.example.entity.ThirdDeduct;
import org.example.service.IAccountService;
import org.example.service.IMqLogService;
import org.example.service.INetRepayPlanService;
import org.example.service.IRepayPlanService;
import org.example.service.IThirdDeductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title : TestController
 * @Description: :
 * @author: libo@juzishuke.com
 * @date: 2023/11/20 13:53
 * @Version:1.0
 */
@Slf4j
@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    private IMqLogService mqLogService;

    @Autowired
    private INetRepayPlanService netRepayPlanService;

    @Autowired
    private IRepayPlanService repayPlanService;

    @Autowired
    private IThirdDeductService thirdDeductService;

    @Autowired
    private IAccountService accountService;

    @RequestMapping("one")
    public Map getAll() {
        Map res = new HashMap();
        HintManager hintManager = HintManager.getInstance();
        res.put("third_deduct", thirdDeductService.getBySharding(0,1,new String[]{"214"},Arrays.asList(0),Arrays.asList(1),new Date(),new Date()));
//        try {
//            hintManager.addTableShardingValue("third_deduct", 0);
//            QueryWrapper<ThirdDeduct> queryWrapper = new QueryWrapper<>();
//            queryWrapper.lt("create_time",new Date());
//            queryWrapper.lt("id",10000L);
//            res.put("third_deduct", thirdDeductService.list(queryWrapper));
//        } finally {
//            hintManager.close();
//        }
//        res.put("repay_plan",
//                repayPlanService.actualNodeRepayDay("repay_plan_0", new Date(), new Date(),
//                        Collections.singletonList("212"), 0L, 10L));
//        res.put("repay_plan2",
//                repayPlanService.listByIdsWithTable(Arrays.asList(1L,2L), "repay_plan_0"));
//        res.put("account", accountService.listByIds(Arrays.asList(1L)));
//        res.put("net_repay_plan", netRepayPlanService.getById(1L));
//        res.put("mq_log", mqLogService.getById(1L));
        return res;
    }

}
